import { Button, LineEdit } from "std-widgets.slint";

export component MainWindow inherits Window {
    title: "Excel 拆分工具";
    width: 400px;
    height: 250px;

    callback select_file_clicked();
    callback select_output_dir_clicked();
    callback split_clicked();
    callback row_count_edited(string);

    in-out property <string> excel_path;
    in-out property <string> output_dir;
    in-out property <string> row_count;

    VerticalLayout {
        alignment: start;
        spacing: 8px;
        padding: 8px;

        HorizontalLayout {
            alignment: start;
            spacing: 8px;
            Button { text: "选择 Excel 文件"; clicked => { select_file_clicked(); } }
            LineEdit { text: root.excel_path; read-only: true; placeholder-text: "请选择 Excel 文件"; }
        }

        HorizontalLayout {
            alignment: start;
            spacing: 8px;
            Button { text: "选择输出目录"; clicked => { select_output_dir_clicked(); } }
            LineEdit { text: root.output_dir; read-only: true; placeholder-text: "请选择输出目录（可选）"; }
        }

        HorizontalLayout {
            alignment: start;
            spacing: 8px;
            Text { text: "拆分行数:"; }
            LineEdit {  text: root.row_count; placeholder-text: "请输入拆分行数"; edited(text) => { row_count_edited(text);} }
        }

        HorizontalLayout {
            alignment: center;
            Button { text: "拆分"; clicked => { split_clicked(); } }
        }
    }
}